<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/hanshu.js"></script>
</head>

<body>
    <script>
        let arr = [40, 35, 20, 30, 15];
        // 设定擂主,让数组里面的数字都无法比过它,应设置无穷大
        // let min = Infinity;
        // 设置循环,让数组里面的数字逐个与擂主比较,筛选最小
        /* for (let i = 0; i < arr.length; i++) {
            if (arr[i] < min) {
                min = arr[i];
            }
        }
        console.log(min); */
        // 转换函数
        /* function getArrMin() {
            let min = Infinity;
            for (let i = 0; i < arr.length; i++) {
                if (arr[i] < min) {
                    min = arr[i];
                }
            }
            return min
        } */
        let res = getArrMin(arr);
        console.log(res);
        let res1 = getArrMax(arr);
        console.log(res1);
        let res2 = getArrSum(arr);
        console.log(res2);
        let res3 = getArrMean(arr);
        console.log(res3);
        let res4 = getArrFan(arr);
        console.log(res4);
    </script>
</body>

</html>